<?php
require('../../public/connection.php');
require('../../class/Mysql.php'); 
$data = json_decode(file_get_contents('php://input'), true);
$data["finished"] = (int)$data["finished"];
if (empty($data["title"]) || $data["finished"] > 1) {
    die(json_encode(array("code" => 400, "msg" => "格式错误")));
}
$time = getDateTime();
$add_one_data = new Mysql();
$result = $add_one_data->addOrEditData(
    "insert into todolist values(null,'{$data["title"]}','{$data["remarks"]}',{$data["finished"]},'{$time}');"
); 
die(json_encode($result));
